
<%@ page import="com.surelution.projects.echo.domain.Status"%>
<%@ page import="com.surelution.projects.echo.domain.Blog" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'blog.label', default: 'Blog')}" />
        <resource:dateChooser />
        <resource:richTextEditor type="advanced"/>
        <title><g:message code="default.list.label" args="[entityName]" /></title>
    </head>
    <body>
       <sec:ifLoggedIn>
        <div class="nav" >
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
				<div   style='float: right'>
				当前用户：<sec:username />&nbsp;&nbsp;<g:link controller="user">修改密码</g:link>&nbsp;<g:link controller="logout">退出</g:link>
				</div>
       	</div>
       </sec:ifLoggedIn>
        <div class="body">
            <sec:ifLoggedIn>
            <g:form action="list">
            <div class="test">
        		起始日期：<richui:dateChooser name="dateFrom" value="${params.dateFrom }" format="yyyy-MM-dd" locale="zh_CN" class="search1"/> －
        		结束日期：<richui:dateChooser name="dateTo" value="${params.dateTo }" format="yyyy-MM-dd" locale="zh_CN" class="search1"/>
        		<g:set var="statuses" value="${com.surelution.projects.echo.domain.Status.getAll()}"/>
        		类型：<g:select name="type" from="${statuses}" optionKey="key" optionValue="label" value="${params.type}"/>
        		
        		<g:submitButton name="list" class="save" value="${message(code: 'default.button.search.label', default: 'Search')}" />
        	</div>
        	</g:form>
			</sec:ifLoggedIn>
            <div class="list">
            <h1><g:message code="default.list.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <table>
                    <thead>
                        <tr>
                            <g:sortableColumn property="title" title="${message(code: 'blog.title.label', default: 'Title')}" />
                            <g:sortableColumn property="type" title="${message(code: 'blog.createTime.label', default: 'Create Time')}" />
                        
                        </tr>
                    </thead>
                    <g:each in="${blogInstanceList}" status="i" var="blogInstance">
					<tr>
	              	<td width="50%">
	      				<g:link action="show" id="${blogInstance.id}">
		      				<font size="3">
		      					<richui:teaser length="16" value="${blogInstance.title.empty?'无标题':blogInstance.title}"/>
		      				</font>
	      				</g:link>
	      			</td>
	      			<td>
	      				<g:formatDate date="${blogInstance.createTime}" format="yyyy年MM月dd日 HH点mm分"/>
	      			</td>
      			</tr>
     		</g:each>
     		</table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${blogInstanceTotal}" style="width:300px"/>
            </div>

		<sec:ifLoggedIn>
		<div id="test">
            <div class="list">
            <h1><g:message code="default.newlist.label" args="[entityName]" /></h1>
            <table>
                    <thead style="height:20px;">
                        <tr>
                            <g:sortableColumn property="title" title="${message(code: 'blog.title.label', default: 'Title')}" />
                            <g:sortableColumn property="type" title="${message(code: 'blog.createTime.label', default: 'Create Time')}" />
                        
                        </tr>
                    </thead>
                    <g:each in="${newBlogList}" status="i" var="newBlog">
					<tr>
	              	<td width="50%">
	      				<g:link action="show" id="${newBlog.id}">
		      				<font size="3">
		      					<richui:teaser length="16" value="${newBlog.title.empty?'无标题':newBlog.title}"/>
		      				</font>
	      				</g:link>
	      			</td>
	      			<td>
	      					<g:formatDate date="${newBlog.createTime}" format="yyyy年MM月dd日 HH点mm分"/><%--
	      				<g:form>
                       		<g:actionSubmit  action="delete" id="${newBlog.id}" value="${message(code: 'default.delete.label', default: 'Del')}" />
	      				</g:form>
	      				--%></td>
      				</tr>
     				</g:each>
     		</table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${newBlogTotal}" style="width:300px"/>
            </div>
		</div>
		<div id="test">
            <div class="list">
            <h1><g:message code="default.readlist.label" args="[entityName]" /></h1>
            <table>
                    <thead>
                        <tr>
                            <g:sortableColumn property="title" title="${message(code: 'blog.title.label', default: 'Title')}" />
                            <g:sortableColumn property="type" title="${message(code: 'blog.createTime.label', default: 'Create Time')}" />
                        
                        </tr>
                    </thead>
                    <g:each in="${readBlogsList}" status="i" var="readBlog">
					<tr>
	              	<td width="50%">
	      				<g:link action="show" id="${readBlog.id}">
		      				<font size="3">
		      					<richui:teaser length="16" value="${readBlog.title.empty?'无标题':readBlog.title}"/>
		      				</font>
	      				</g:link>
	      			</td>
	      			<td>
	      				<g:formatDate date="${readBlog.createTime}" format="yyyy年MM月dd日 HH点mm分"/>
	      			</td>
      			</tr>
     		</g:each>
     		</table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${readBlogTotal}" style="width:300px"/>
            </div>
		</div>

		</sec:ifLoggedIn>
            <h1><g:message code="default.new.label" args="[entityName]" /></h1>
            <g:form action="save" >
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="title"><g:message code="blog.title.label" default="Title" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: blogInstance, field: 'title', 'errors')}">
                                    <g:textField name="title" value="${blogInstance?.title}" style="width:400px"/>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                   <label for="content"><g:message code="blog.content.label" default="Content" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: blogInstance, field: 'content', 'errors')}">
                                   <richui:richTextEditor name="content" value="${blogInstance?.content}" width="400" height="150" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
